var wsUrl = 'ws://39.98.144.29:6061';

var webSocket = new WebSocket(wsUrl);

//实例化对象onOpen 属性
webSocket.onopen = function (evt) {
    webSocket.send("live.js");
    console.log("connected-swoole-success");
}
//实例化对象onmessage
webSocket.onmessage = function (evt) {
    push(evt.data);
    console.log('ws-server-request-data:' + evt.data);
}

//实例化close事件
webSocket.onclose = function (evt) {
    console.log('colse-swoole');
}
//onerror
webSocket.onerror = function (evt, e) {
    console.log("error:" + evt.data)
}
function push(data)
{
    data = JSON.parse(data);
    var html = '<div class="frame">';
    html +='<h3 class="frame-header">';
    html +='<i class="icon iconfont icon-shijian"></i>第'+data.type+'节 05：30';
    html +='</h3>';
    html +='<div class="frame-item">';
    html +='<span class="frame-dot"></span>';
    html +='<div class="frame-item-author">';
    if(data.logo){
        html +='<img src="'+data.logo+'" width="20px" height="20px"/>';
    }
    html +=data.title;
    html +='</div>';
    html +='<p>'+data.content+'</p>';
    if(data.image){
        html +='<p>';
        html +='<img src="http://'+data.image+'" width="40%" />';
        html +='</p>';
    }
    html +='</div>';
    html +='</div>'
    console.log(html)

    $('#match-result').prepend(html);
}